﻿using AutoMapper;
using BPMN.Application.Contracts.DTO.Request.Brands;
using BPMN.Application.Contracts.DTO.Request.RepairOrders;
using BPMN.Application.Contracts.DTO.Response;
using BPMN.Application.IService;
using BPMN.Domain.Entity.EmployeePerformance;
using BPMN.DomianShare;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BPMN.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RepairOrdersController : ControllerBase
    {
        private readonly IRepairOrdersAppService appService;

        public RepairOrdersController(IRepairOrdersAppService appService)
        {
            this.appService = appService;
        }

        /// <summary>
        /// 维修单显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetRepairOrders(string? RName, string? Rremark, string? EName)
        {
            return Ok(await appService.GetRepairOrders(RName, Rremark, EName));
        }

        /// <summary>
        /// 维修单单独显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetRepairs()
        {
            return Ok(await appService.GetRepairs());
        }

        /// <summary>
        ///  维修单添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> AddRepairOrders(RepairOrdersRequestDto entity)
        {
            return Ok(await appService.AddRepairOrders(entity));
        }

        /// <summary>
        /// 根据Id获取角色信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetRepairOrdersById(int Rid)
        {
            return Ok(await appService.GetRepairOrdersById(Rid));

        }
        /// <summary>
        /// 修改功能
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IActionResult> UpdateRepairOrders(RepairOrdersRequestDto entity)
        {
            return Ok(await appService.UpdateRepairOrders(entity));
        }

        /// <summary>
        /// 品牌信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetBrandsList()
        {
            return Ok(await appService.GetBrandsList());
        }
    }
}
